package com.szy.douyou_article.web;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.model.Bucket;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.region.Region;
import com.szy.douyou_article.config.ResultDTO;
import com.szy.douyou_article.service.FileUploadService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * 文件上传
 * @author sunziyan
 * @date 2022/4/2
 */
@RestController
public class FileUploadController {

    @Resource
    private FileUploadService fileUploadService;



    @PostMapping("/getImageUploadUrl")
    public ResultDTO getImageUploadUrl(@RequestParam("image")MultipartFile multipartFile){
        if(multipartFile.isEmpty()){
            return ResultDTO.fail("文件为空");
        }

        return ResultDTO.success(fileUploadService.getImageUploadUrl(multipartFile));

    }





}
